package com.futao.springbootlearn20220224.validdemo;

import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author futao@gmail.com
 * @date 2022/3/28
 */
@RequestMapping("/valid")
@RestController
public class ValidController {

    @PostMapping("/body")
    public ValidObject validBody(
            @RequestBody
            // 对于requestBody的校验，需要将注解标记在body上，且是以"valid"开头的注解
            @Validated ValidObject validObject) {
        return validObject;
    }
}




